package com.itheima.edu.info.manager.day14;

import java.util.concurrent.Semaphore;

public class SemaphoreTest implements Runnable{
    Semaphore s=new Semaphore(3);
    @Override
    public void run() {
        try {
            s.acquire();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("获得通行证");
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("归还");
        s.release();
    }
}
